package com.xxx;

import java.io.DataOutputStream;
import java.io.OutputStream;
import java.net.Socket;
import java.util.Scanner;

public class ClientB extends Thread{
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        Thread serverB = new ServerB();
        serverB.start();

        while (true) {
            try {
                Socket B =new Socket("127.0.0.1", 6666);
                OutputStream os = B.getOutputStream();
                DataOutputStream dos = new DataOutputStream(os);
                while (true) {
                    String rd = sc.next();
                    if ("exit".equals(rd)){
                        System.out.println("退出成功");

                        B.close();

                        dos.close();
                        return;
                    }
                    dos.writeUTF("客户端B："+rd);
                    dos.flush();
                }

            } catch (Exception e) {

            }
        }
    }

}
